


class Dog(object):
    def __init__(self,name):
        self.name = name

    def eat(self,food):
        print("%s is eating..."%self.name,food)

# d = Dog('xiaowang')
# choice = input('>>:').strip()
# getattr(d,choice)
name = ['abc',123]
data = {}
# try:
    # name[3]#执行到这，，后面就不执行了，，
    # data['name']

#     open('tes.txt')
# except FileNotFoundError as e:
#      print("出错了",e)

# except Exception as e:#抓住所有错误，，一般不用
#     print("出错了",e)

# except (KeyError,IndexError) as e:#n种错误采取同一种方式解决
#    print("没有这个key",e)
#缩进错误，，Base错误是抓不到的
#int字符出value错误
try:
    open('tes.txt')
    # a=1
    # print(a)
except KeyError as e:
       print("没有这个key",e)
except IndexError as e:
        print("列表操作错误",e)
except Exception as e:
    print('未知错误',e)
else:
    print('一切正常')
finally:
    print("不管有没有错，都执行")

